<%-- 
    Document   : index
    Created on : Apr 16, 2012, 3:15:37 PM
    Author     : Prateek ,Rahul , Rakesh
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
 <%@page import="java.sql.*"%>
 <%@page import="cs425proj.model.*" %>
 <%@page import="cs425proj.servlets.*" %>
 <%@page import="java.util.*" %>
 
 
 <%
        response.setHeader("Cache-Control","no-cache"); //Forces caches to obtain a new copy of the page from the origin server
        response.setHeader("Cache-Control","no-store"); //Directs caches not to store the page under any circumstance
        response.setDateHeader("Expires", 0); //Causes the proxy cache to see the page as "stale"
        response.setHeader("Pragma","no-cache"); //HTTP 1.0 backward compatibility
        %>
        <%String name = (String) session.getAttribute("name");%>
        <% if (null == name) { %>
<!DOCTYPE html>
<html>
    
    <head>
         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
                
        <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
        <script type="text/javascript">
            $(function() {
                initCountry();
                
            });
            
            function initCountry(response) {
                initSelectHierarchy('country','state.jsp','state-wrapper',initState);
            }
            function initState(response) {
                initSelectHierarchy('state','city.jsp','city-wrapper',initCity);
                
            }
            function initCity(response) {
                initSelectHierarchy('city','theater2.jsp','theater-wrapper',function(res){});
                
            }
            
            
            
            function initSelectHierarchy(selectBoxId, jspFile, childWrapperId, successFunc) {
                $('#'+selectBoxId).change(function() {
                    var val = $(this).val();
                    
                    //alert('Country: '+country);
                    $.ajax({
                        method: 'GET',
                        url: jspFile,
                        data: {'count':val},
                        success: function(responseHtml) {
                            //alert(html);
                            $('#'+childWrapperId).html(responseHtml);
                            successFunc.call(responseHtml);
                            //successFunc();
                        },
                        failure: function() {
                            alert('Unable to get data.');
                        }
                    });
                });
            }
        </script>
       </head>
    <body>
        <%@page import="javax.servlet.http.Cookie"%>

 
        <table align="center">
            <thead>
                <tr>
                    <th><h1>CS 425 Project </h1></th>
                </tr>
            </thead>
        </table>

        <table border="1" width="900"  align="center" >
             <tbody>
                <tr>
                    <td width="450"  >
                                <form action="newTicket.jsp" method="post"> 
                        <table  align="center">
                            <tr><td>
                                     
                                    <table>
                                       
                                        <tr>
                                            <td>
                                                                              
                                    <div id="country-wrapper">
                                    <select name='country' id="country">
                        <option value="none">Location</option>  
                        <%
                   theaterDetail tdobj = new theaterDetail();
                   ArrayList<String> cityList = tdobj.getCityList();
                    for(int j=0;j<cityList.size();j++){
                        String dism =cityList.get(j);
                        %>
                        <option value="<%=dism%>"><%=dism%></option>  
                        <%
                    }
                        %>
                        </select>  
                                    </div>
                                            </td>
                                            <td><div id='state-wrapper'></div></select> </td>
                                            <td><div id='city-wrapper'></div></td>
                                        </tr></table>
                        <div id='list-wrapper'></div>
                                </td></tr>
                                <tr><td>  
                                    <div id='list'> 
                                        <p name='list'>
                                        </p>
                                    </div>
                                </td></tr>
                                <tr><td align="center">
                                <input type="submit" name="buy" value="buy" align="right">
                                
                                    
                                    </td></tr>
                                                   
                                
                       </table>
                                                            
                        </form>                        
                          
                   </td>
                    <td width="450">
                       <form name="loginform" method="get" action="RequestForward">
                           
                            <table align="center"><tr><td><h2>Member Login</h2></td></tr></table>
                            <table width="300px" align="center" style="border:1px solid #000000;background-color:#efefef;">
                            <tr><td colspan=2></td></tr>
                            <tr><td colspan=2> </td></tr>
                            <tr>
                            <td><b>Login Name</b></td>
                            <td><input type="text" name="username" value=""></td>
                            </tr>
                            <tr>
                            <td><b>Password</b></td>
                            <td><input type="password" name="password" value=""></td>
                            </tr>
                            <tr>
                            <td></td>
                            <td><input type="submit" name="submit" value="Submit"></td>
                            
                            </tr>
                            
                            <tr><td colspan=2> </td></tr>
                            </table>
                        </form>
                       
                        <FORM METHOD="LINK" ACTION="newuser.jsp" align="center">
                            <INPUT TYPE="submit" VALUE="New User">
                            </FORM>
                                              
                    
                    </td>
                </tr>
                
            </tbody>
        </table>
                        <table border="1" width="900"  align="center" >
                            <tr align="center" >
                           <td>

                               <p><h1>Discussion Forum</h1></p>
                               
                                
                                     
 <% disDetail obj = new disDetail();
 ArrayList<String> dislist = obj.getRecentDisscusion();
 for(int k =0 ;k<dislist.size();k++){
   String item[] = dislist.get(k).split(";");
   String tag = "dis"+(k+1); 
  %>  
  <form action="displayDiscusion" method="get">
  <p> <input type="submit" name="<%=tag%>" value="<%=item[0]%>"> 
      
 </input> <%=item[1]%>  </p>           
       
  </form>                
                            <%}%>
          </td> 

       
       


                                    
                                
                            </tr>
                        </table>
                         <table border="1" width="900"  align="center" >
                            <tr align="center" >
                                <td>
                                    
                                    Employee Access .  <FORM METHOD="LINK" ACTION="internal/index.jsp" align="center">
                            Please click <INPUT TYPE="submit" VALUE="Here"><br/>
                            <a href="theater.jsp"> Enter Theater</a>
                            </FORM><br/>
                            <a href="movie.jsp"> Enter Movie</a><br/>
                            <a href="enterSchedule.jsp">Enter Schedule</a>
                            </FORM>
                                </td>
                            </tr>
                        </table>

    </body>
</html>
 <%}%>
 
